//
//  TraeNode.m
//  Conference Track Management
//
//  Created by Jiang on 2018/10/22.
//  Copyright © 2018 jiang. All rights reserved.
//

#import "TraceNode.h"

@implementation TraceNode
{
    NSArray <id <Talk>>* _talks;
}
- (instancetype)initWithTalk:(id <Talk>)talk lastNode:(TraceNode *)lastNode{
    self = [super init];
    _currentTalk = talk;
    _talks = nil;
    _lastNode = lastNode;
    return self;
}
- (NSArray<id <Talk>> *)talks{
    if (!_talks) {
        NSMutableArray *talks = [NSMutableArray array];
        TraceNode *tmpNode = self;
        while (tmpNode) {
            [talks addObject:tmpNode->_currentTalk];
            tmpNode = tmpNode->_lastNode;
        }
        _talks = [talks copy];
    }
    return _talks;
}
@end
